package 泛型;

public class Point4<T> implements IMessage<T> {
    private T mag;
    @Override
    public void print(T t) {

    }
    public static void fun(IMessage<?> num){
//        num.setMag("123");
        System.out.println(num.getMag());
    }


    public T getMag() {
        return mag;
    }

    public void setMag(T mag) {
        this.mag = mag;
    }

    public static void func(IMessage<? extends Number> ms){
//        ms.setMag(123);
        System.out.println(ms.getMag());
    }
    public static void function(IMessage<? super String> ms){
//        ms.setMag(123);
        System.out.println(ms.getMag());
    }

    public static void main(String[] args) {
//        IMessage<Integer> img = new Point4();
//        img.setMag(13);
//        fun(img);
        IMessage<String> iMessage = new Point4<>();
        iMessage.setMag("tree");
        fun(iMessage);
        IMessage<Integer> img1 = new Point4<>();
        img1.setMag(123);
        func(img1);
        System.out.println(img1.getClass() == iMessage.getClass());
//        IMessage<Double> img2 = new Point4<>();
//        img2.setMag(12.45);
//        func(img2);
//        IMessage<String> img3 = new Point4<>();
//        img3.setMag("re");
//        func(img3);
//        IMessage<String> ims1 = new Point4<>();
//        ims1.setMag("123");
//        function(ims1);
//        IMessage<Integer> ims2 = new Point4<>();
//        ims2.setMag(123);
//        function(ims2);
    }

}
